<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link rel="shortcut icon" href="__IMG__/favicon.ico" />
	<link rel="bookmark" href="__IMG__/favicon.ico" type="image/x-icon" 　/>
	<title>广州快乐十分</title>
	<link rel="stylesheet" type="text/css" href="__CSS__/mui.min.css"/>
	<link rel="stylesheet" type="text/css" href="__CSS__/common.css"/>
	<link rel="stylesheet" type="text/css" href="__CSS__/index.css"/>
	<script src="__JS__/mui.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript" charset="utf-8">
        mui.init();
	</script>
	<style>
		.style_tab tr:nth-child(2n) td{
			border-left: 1px solid #e0dfe3;
		}
		.spring_box3 table{
			border: none;
			width: 100%;
			text-align: center;
		}
		.spring_box3 table th,.spring_box3 table td{
			padding: 5px 0;
		}
		.spring_box3 table input[type=number]{
			width: 80px;
			margin: 0;
			padding: 5px;
			height: 25px;
			background: #e2e2e2;
			border:1px solid #D2D2D2;
			color: #E22C2B;
			text-align: center;
		}
		.spring_box3 .table_box{
			min-height: 300px;
		}
		.spring_box3{
			width: 80%;
			background: #fff;
			position: fixed;
			top: 10%;
			left: 10%;
			z-index: 50;
			display: none;
			box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, .5);
		}
		.table_box{
			overflow: auto;
		}
		.spring_box4{
			width: 100%;
			height: 78px;
			position: fixed;
			bottom: 0;
			left:0;
			z-index: 101;
			background: rgba(0,0,0,.3);
			display: none;
		}


	</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
	<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	<h1 class="mui-title">广州快乐十分</h1>
	<a class="mui-pull-right mui-h5 blue box1_a  mg_top5"><i id="balance">{$balance}</i><span class="mui-h2 padding_lr10">...</span>	</a>
</header>
<div class="mui-content">
	<div class="play_top">
		<div class="clearfix">
			<div class="left play_top_left">
				<p class="color_ff">第<span>{$stage_data['stage']}</span>期</p>
			</div>
			<div class="left play_top_right">
				<div class="round_box">
					{foreach $stage_data['number'] as $k=>$v}
					<i class="round">{$v}</i>
					{/foreach}
				</div>
				<div class="squal_box">
					{foreach $stage_data['detail'] as $k=>$v}
					<i>{$v}</i>
					{/foreach}
				</div>
			</div>
		</div>
		<div class="clearfix padding_tb10">
			<div class="left play_top_left top2">
				<p class="color_ff">第<span id="next_stage">{$stage_data['stage_next']}</span>期</p>
			</div>
			<div class="left play_top_right clearfix">
				<span class="left color_ff ">剩余：</span>
				<div class="colockbox clearfix left" id="demo02">
					<span class="hour">00</span>
					<span class="minute">00</span>
					<span class="second">00</span>
				</div>
				<span class="left color_ff">开奖：</span>
				<div class="colockbox clearfix left" id="demo03">
					<span class="hour">00</span>
					<span class="minute">00</span>
					<span class="second">00</span>
				</div>
			</div>
		</div>
	</div>
	<div class="play_mian">
		<div class="clearfix">
			<div class="left play_left">
				<ul class="play_list">
					{foreach $pan as $k=>$v}
					<li {if $k==0} class="active" {/if}><a href="javascript:void(0);">{$v['name']}</a></li>
					{/foreach}
				</ul>
			</div>
			<div class="left play_right my_td">
				{foreach $odds as $k=>$v}
				<div class="play_div {if $k==0} active {/if}">
					<table border="" cellspacing="" cellpadding="" class="style_tab" >
						{foreach $v['titles'] as $kk=>$vv}
						<tr>
							<th colspan="2">{$vv['type_name']}</th>
						</tr>
						{foreach $vv['type_odd'] as $kkk=>$vvv}
						<tr style="float: left;width: 50%">
							<td style="display: inline-block;width: 100%;border:1px solid #e0dfe3;border-top: none;border-left: none;">
								<i style="font-weight: bold">{$vvv['rule']}</i>
								<span style="font-weight: bold">{$vvv['rate']}</span>
								<input type="hidden" value="{$vv['type_name']}">
								<input type="hidden" value="{$vv['type']}">
							</td>
						</tr>
						{/foreach}
						{/foreach}
					</table>
				</div>
				{/foreach}
			</div>
		</div>
	</div>
</div>
<div class="aside">
	<a href="{:url('mine/service')}"  class="right sever_box"><img class="width_100 mg_top5" src="__IMG__/icon_service.png" alt="" /></a>
</div>
<div class="footer">
	<h6 class="padding_5">已选：<span id="is_choose">0</span>注</h6>
	<div class="clearfix padding_lr10 mg_top5">
		<div class="left mui-col-sm-8">
			<input type="number"  id="money" value="" placeholder="请输入金额" />
			<input type="hidden" name="" id="dateline" value="{$stage_data['dateline']}"  />
			<input type="hidden" name="" id="lottery_time" value="{$stage_data['lottery_time']}"/>
			<input type="hidden" name="" id="cate" value="{$cate}"/>
		</div>
		<div class="right mui-col-sm-4">
			<input type="button" id="ok" value="确定" class="bg_red color_ff mg_top10 box3_a" />
			<input type="reset" id="cz" value="重置"  class="bg_blue color_ff mg_top10"/>
		</div>
	</div>
</div>
<div class="spring_box1">
	<ul>
		<li class="bor_b"><a href="{:url('mine/transaction_record',array('cate'=>$cate))}">投注记录</a></li>
		<li class="bor_b"><a href="{:url('lottery/history',array('cate'=>$cate))}">开奖结果</a></li>
		<li><a href="{:url('web/play_rule_web',array('cate'=>$cate))}">游戏规则</a></li>
	</ul>
</div>
<div class="spring_box3">
	<div class="padding_10">
		<h4 class="blue text-center mg_tb10 clearfix">确定注单<span class="right padding_lr10" id="go_out"><img src="__IMG__/error.png" alt="" /></span> </h4>
		<div class="table_box bor_b">
			<table border="" cellspacing="" cellpadding="">
				<tr>
					<th>项目</th>
					<th>赔率</th>
					<th>金额</th>
					<th>删除</th>
				</tr>
			</table>
		</div>
		<p class="text-center padding_10">余额：<span>{$balance}</span></p>
		<div class="clearfix padding_10">
			<div class="left">
				注数：<span class="red1" id="total_zhu">5</span>
			</div>
			<div class="right">
				总额：<span class="red1" id="total_money">5.00</span>
			</div>
		</div>
		<div class="clearfix padding_10">
			<div class="right">
				<input class="bg_blue color_ff" type="button" onclick="betting()" value="确认下注" />
			</div>
		</div>
	</div>
</div>
<div class="spring_box4">
	<p class="color_ff text-center" style="line-height: 78px">
		本期已封盘，停止下注
	</p>
</div>

<div class="overlay"></div>
<script src="__JS__/jquery-1.7.1.min.js"></script>
<script src="__JS__/time.js" type="text/javascript" charset="utf-8"></script>
<script src="__JS__/index.js"></script>
<script src="__JS__/layer.js" ></script>
<script src="__JS__/rooms.js" ></script>
<script>
    $(function() {
        $(".table_box").css({"max-height":$(document).height()/3});
        //点击加注
        $('.my_td table td').click(function () {
            var number = $('.my_td table td.active').length;
            number = parseInt(number);
            $('#is_choose').html(number);
        });
    });
    //浮动层删除
    $(document).on("click",".dell",function() {
        $(this).parent().parent().remove();
        var zhu = parseInt($('#total_zhu').html());
        zhu = zhu-1;
        $('#total_zhu').html(zhu);
        var my_moneys = 0;
        $('.my_number').each(function () {
            var my_money =parseInt($(this).val());
            my_moneys = my_moneys+my_money;
        });
        $('#total_money').html(my_moneys);
    });
    //浮动层改变金额的值
    $(document).on("blur",".my_number",function() {
        var my_moneys = 0;
        $('.my_number').each(function () {
            var my_money =parseInt($(this).val());
            my_moneys = my_moneys+my_money;
        });
        $('#total_money').html(my_moneys);

    });

    //浮动层关闭
    $("#go_out").click(function(){
        out();
    });
    //清除所有active
    $("#cz").click(function(){
        $('.my_td table td.active').removeClass("active");
        $('#is_choose').html(0);
    });
    //浮动层关闭方法
    function out() {
        $(".overlay").hide();
        $(".spring_box3").fadeOut(200);
        $('.table_box table tr.tj').remove();
    }
    //将数据添加到浮动层
    $("#ok").click(function(){
        var number =  $('.my_td table td.active').length;
        if(number<=0){
            my_error('请选择投注项');
            return false;
        }
        var money = $('#money').val();
        if(money=="" || money==0){
            my_error('请输入投注金额');
            return false;
        }
        var number_arr=[];
        $('.my_td table td.active').each(function () {
            var odds   = $(this).find('span').html();
            var number = $(this).find('i').html();
            var type   = $(this).find('input:eq(0)').val();
            var type_id = $(this).find('input:eq(1)').val();
            list = {};
            list['odds']     = odds;
            list['number']   = number;
            list['type']     = type;
            list['money']    = money;
            list['type_id']  = type_id;
            number_arr.push(list);
        });
        var str = "";
        for (var i=0;i<number_arr.length;i++) {
            str += "<tr class='tj'>"
                + "<td>"+number_arr[i].type+"@"+"<i>"+number_arr[i].number+"</i></td>"
                + "<td>"+number_arr[i].odds+"</td>"
                + "<td>"+"<input type='number' class='my_number'  value="+number_arr[i].money+">"
                + "</td>"
                + "<td><img class='dell' src='__IMG__/dell.png'/>"
                + "</td>"
                + "<td>"+"<input type='hidden'  value="+number_arr[i].type_id+">"
                + "</tr>"
        }
        $('.table_box table').append(str);
        var total_zhu =  $('.my_td table td.active').length;
        var total_money = total_zhu*money;
        $('#total_zhu').html(total_zhu);
        $('#total_money').html(total_money);
    });
    //下注
    function betting() {
        var stage = $('#next_stage').html();
        var cate = $('#cate').val();
        var number_arr=[];
        $('.table_box table tr.tj').each(function(){
            var money  =  $(this).find('input:eq(0)').val();
            var type   =  $(this).find('input:eq(1)').val();
            var number =  $(this).find('i').html();
            list = {};
            list['type']   = type;
            list['number'] = number;
            list['money']  = money;
            number_arr.push(list);
        });
       // console.log(number_arr);
        var list1 = JSON.stringify(number_arr);
        $.ajax({
            type: "post",
            url: "{:url('game/betting')}",
            data: {'cate':cate,'stage':stage,'hall':1,'list':list1},
            dataType: "json",
            async: false,
            success: function(data) {
                var ret   = data.ret;
                var info  = data.msg;
                var blance = data.data.money;
                if(ret=='200'){
                    $('#balance').html(blance);
                    out();
                    $('.my_td table td.active').removeClass("active");
                    my_error(info);
                }else{
                    my_error(info);
                }
            }
        });

    }

</script>
</body>
</html>
